// pages/meetingCreate/meetingCreate.js
const app = getApp()
var that;
var util = require('../../utils/util.js');
Page({

  data: {
    roomList:[],
    meetingObj: {
      "applicant": "",
      "companyId": 0,
      "content": "",
      "createTime": "",
      "department": "",
      "endTime": "",
      "endTimeShow": "16:00",
      "fileNums": 0,
      "id": 0,
      "inviteNums": 0,
      "joinNums": 0,
      "ma": "",
      "phone": "",
      "picNums": 0,
      "riqi": "",
      "roomId": 0,
      "stage": 0,
      "startTime": "",
      "startTimeShow": "15:00",
      "status": 0,
      "summary": "",
      "title": "",
      "type": 0,
      "updateTime": "",
      "userId": "",
      "roomName":"",
    }
  },

  onLoad: function (options) {
    that = this;

    let now = new Date();
    let year = now.getFullYear();
    let month = now.getMonth() + 1;
    let day = now.getDate();


    that.data.meetingObj.riqi = year + "-" + month + "-" + day;
    that.setData({
      meetingObj: that.data.meetingObj
    })

    wx.getStorage({
      key: 'roomList',
      success: function(res) {
        that.setData({
          roomList:res.data
        })
      },
    })

    console.log("data",that.data)
  },

  //名称
  inpNameFun: function (e) {
    that.data.meetingObj.title = e.detail.value;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  // 会议室
  chooseRoomFun:function(e){
    // console.log("e",e)
    let index = e.detail.value;
    that.data.meetingObj.roomName = that.data.roomList[index].name;
    that.data.meetingObj.roomId = that.data.roomList[index].id;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  // 日期
  chooseRiqiFun: function (e) {
    // console.log("e",e)
    that.data.meetingObj.riqi  = e.detail.value;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  // star时间
  chooseStarTimeFun: function (e) {
    console.log("e",e)
    that.data.meetingObj.startTimeShow = e.detail.value;
    that.data.meetingObj.startTime = that.data.meetingObj.riqi + " " + e.detail.value;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  // end时间
  chooseEndTimeFun: function (e) {
    console.log("e", e)
    that.data.meetingObj.endTimeShow = e.detail.value;
    that.data.meetingObj.endTime = that.data.meetingObj.riqi + " " + e.detail.value;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  //会议内容
  inpContentFun: function (e) {
    that.data.meetingObj.content = e.detail.value;
    that.setData({
      meetingObj: that.data.meetingObj
    })
  },

  // 邀请参会人员
  toYaoFun:function(){
    wx.navigateTo({
      url: '/pages/meetingDetailJoinList/meetingDetailJoinList',
    })
  },

  // 会议类型
  chooseTypeFun:function(e){
    wx.showActionSheet({
      itemList: ['内部会议-本组织机构可参加', '公开会议-所有人都可参加'],
      success(res) {
        console.log(res.tapIndex)
      },
      fail(res) {
        console.log(res.errMsg)
      }
    })
  },

  
})